<?xml version='1.0' encoding='UTF-8' ?>
<ui:composition template="template-without-sidebar.xhtml" xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ice="http://www.icesoft.com/icefaces/component"
                xmlns:odr="http://java.sun.com/jsf/composite/odr"
                xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:define name="head">
        <link rel="stylesheet" type="text/css" href="resources/css/vtip.min.css" />
        <link rel="stylesheet" type="text/css" href="resources/css/jquery-ui-1.8.6.custom.css" />
        <script type="text/javascript" src="resources/js/vtip-min.js"></script>
        <script type="text/javascript" src="resources/js/searchableTable.js"></script>
        <script type="text/javascript" src="resources/js/jquery-ui-1.8.6.custom.min.js"></script>
    </ui:define>

    <ui:define name="pagetitle">
        Decisions
    </ui:define>

    <ui:define name="bodyBegin">
        <odr:deletePopup valid="#{decisionTableController.valid}"
                         message="#{form['table.deletion.decision.text']}"
                         attribute="#{decisionTableController.versionToDelete.decision.name} (#{decisionTableController.versionToDelete.state.statusName})"
                         removeMethod="#{decisionTableController.deleteVersion}"/>
    </ui:define>

    <ui:define name="content">
        <ice:panelGroup rendered="#{decisionTableController.valid}">
            <odr:breadcrumb breadCrumbSource="#{decisionTableController.navigationBar}" />
            <h1><h:outputText value="#{form['table.header.decisions']}"/></h1>
            <a href="#{decisionTableController.createDecisionLink}" ><img class="createConcernSymbol vtip" title="#{form['table.tooltip.create.decision']}" src="resources/images/add.png" alt="#{common['create']}"/></a>

                <label for="searchInput" class="prefillValue" style="display: none">#{form['table.search.input']}</label>
                <input id="searchInput" onkeyup="doFilter(this, 'concernList', true)" style="width: 200px;" class="prefill" onclick="return false;"/>
        </ice:panelGroup>
        <ice:form partialSubmit="true" rendered="#{decisionTableController.valid}">
            <table class="dataList" id="concernList">
                <thead>
                    <tr>
                        <th style="width: 5%; text-align: center">
                            <div title="#{form['table.tooltip.collapseall']}" class="collapseall vtip" onclick="j('.toggleSubTableHide').click();"/>
                            <div title="#{form['table.tooltip.expandall']}" class="expandall vtip" onclick="j('.toggleSubTableShow').click();"/>
                        </th>
                        <th style="width: 23%;">#{form['table.decision.column.name']}</th>
                        <th style="width: 15%;">#{form['table.decision.column.state']}</th>
                        <th style="width: 20%;">#{form['table.decision.column.date']}</th>
                        <th style="width: 37%;">#{form['table.decision.column.initiator']}</th>
                        <th colspan="3" style="">#{form['table.decision.column.actions']}</th>
                    </tr>
                </thead>
                <tbody>
                <ice:repeat value="#{decisionTableController.list}" var="item" id="concernRepeat">
                    <tr class="parentRow group-#{item.decision.id}">
                        <td style="border-bottom: none">
                            <a class="toggleSubTableShow toggleSubTable" href="#" style="display: none"/>
                        </td>
                        <td title="#{item.decision.name}" class="vtip"><ice:outputText value="#{item.decisionName}" nospan="true" >
                        <f:convertDateTime type="date" pattern="#{common['format.date.time']}" timeZone="#{timeZoneController.timeZone}" />
                    </ice:outputText></td>
                    <td>#{item.currentVersion.state.statusName}</td>
                    <td><ice:outputText value="#{item.currentVersion.decidedWhen}" nospan="true">
                        <f:convertDateTime type="date" pattern="#{common['format.date.time']}" timeZone="#{timeZoneController.timeZone}" />
                    </ice:outputText></td>
                    <td title="#{item.getAllInitiators(item.currentVersion)}" class="vtip">#{item.getInitiators(item.currentVersion)}</td>
                    <td><a href="#{decisionTableController.getShowLink(item.currentVersion)}" ><img class="vtip" title="#{form['table.tooltip.details']}" alt="#{common.read}"
                                                                                                    src="resources/images/inspect.png"
                                                                                                    width="14"
                                                                                                    height="14"/></a></td>
                    <td><a href="#{decisionTableController.getUpdateLink(item.currentVersion)}" ><img class="vtip" title="#{form['table.tooltip.edit']}" alt="#{common.edit}"
                                                                                                      src="resources/images/pencilSmall.png"
                                                                                                      width="14"
                                                                                                      height="14"/></a></td>
                    <td><ice:commandLink value=""
                                         actionListener="#{decisionTableController.showDeleteVersionConfirmation}"
                                         styleClass="columnNavigationLink">
                        <img class="vtip" title="#{form['table.tooltip.delete']}" alt="#{common.remove}"
                             src="resources/images/removeSmall.png"
                             width="14"
                             height="14"/>
                        <f:attribute value="#{item}" name="item" />
                        <f:attribute value="#{item.currentVersion}" name="version" />

                    </ice:commandLink></td>
                    </tr>
                    <ice:repeat value="#{item.subVersions}" var="version" id="subconcernRepeat">
                        <tr style="display: none;" class="subRow group-#{item.decision.id}">
                            <td style="border:none;"></td>
                            <td></td>
                            <td>#{version.state.statusName}</td>
                            <td><ice:outputText value="#{version.decidedWhen}" nospan="true">
                            <f:convertDateTime type="date" pattern="#{common['format.date.time']}" timeZone="#{timeZoneController.timeZone}" />
                        </ice:outputText></td>
                        <td title="#{item.getAllInitiators(version)}" class="vtip">#{item.getInitiators(version)}</td>
                        <td> <a href="#{decisionTableController.getShowLink(version)}" ><img class="vtip" title="details" alt="#{common.read}"
                                                                                             src="resources/images/inspect.png"
                                                                                             width="14"
                                                                                             height="14"/></a></td>
                        <td><a href="#{decisionTableController.getUpdateLink(version)}" ><img class="vtip" title="edit" alt="#{common.edit}"
                                                                                              src="resources/images/pencilSmall.png"
                                                                                              width="14"
                                                                                              height="14"/></a></td>
                        <td><ice:commandLink value=""
                                             actionListener="#{decisionTableController.showDeleteVersionConfirmation}"
                                             styleClass="columnNavigationLink">
                            <img alt="#{common.remove}"
                                 src="resources/images/removeSmall.png"
                                 width="14"
                                 height="14"/>
                            <f:attribute value="#{item}" name="item" />
                            <f:attribute value="#{version}" name="version" />

                        </ice:commandLink></td>
                        </tr>
                    </ice:repeat>
                </ice:repeat>
                </tbody>
            </table>
        </ice:form>
    </ui:define>
</ui:composition>